//
//  ContractCell.m
//  阿帕
//
//  Created 阿帕 on 2020/1/4.
//  Copyright © 2020 GCY. All rights reserved.
//

#import "ContractCell.h"

@interface ContractCell ()
@property (nonatomic,strong) CJButton *btnSign;

@end

@implementation ContractCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    NSArray *titleArr = @[@"合同编号", @"发货人", @"金额(元)", @"合同时间"];
    
    for (int i=0; i<titleArr.count; i++) {
        
        UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 40*i, ScreenW, 40)];
        [self.contentView addSubview:bgView];
        
        UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 100, bgView.height)];
        textLabel.text = titleArr[i];
        textLabel.textAlignment = NSTextAlignmentLeft;
        textLabel.textColor = Dark_TextColor;
        textLabel.font = font(14);
        textLabel.adjustsFontSizeToFitWidth = YES;
        [bgView addSubview:textLabel];
        
        UILabel *valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenW - 215, 0, 200, bgView.height)];
        valueLabel.tag = 100 + i;
        valueLabel.text = @"";
        valueLabel.textAlignment = NSTextAlignmentRight;
        valueLabel.textColor = Dark_TextColor;
        valueLabel.font = font(14);
        valueLabel.adjustsFontSizeToFitWidth = YES;
        [bgView addSubview:valueLabel];
        
        if (i<3) {
            UIView *line = [[UIView alloc] initWithFrame:CGRectMake(15, 39, ScreenW-30, 1)];
            line.backgroundColor = BackgroundColor;
            [bgView addSubview:line];
        }
        
    }
    
    [self.contentView addSubview:self.btnSign];
    
    //底部分割线
    UIView *hLine = [[UIView alloc] initWithFrame:CGRectMake(0, self.btnSign.bottom, ScreenW, 10)];
    hLine.backgroundColor = BackgroundColor;
    [self.contentView addSubview:hLine];
}

- (void)setModel:(ContractRecordModel *)model {
    
    _model = model;
    
    NSArray *arr = @[[NSString nullToString:model.contractNo],
                     [NSString nullToString:model.shipperName],
                     [NSString nullToString:model.amount],
                     [NSString nullToString:model.gmtCreated]
    ];
    
    for (int i=0; i<arr.count; i++) {
        UILabel *label = [self.contentView viewWithTag:100+i];
        label.text = arr[i];
    }
}




- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark ----------btnAction

- (void)btnElectSignAction:(UIButton *)sender{
    if (self.blockElectSign) {
        self.blockElectSign(@"");
    }
}
#pragma mark ----------lazy

- (CJButton *)btnSign{
    if (!_btnSign) {
        _btnSign = CJButton.btnInit
        .btnFrame(CGRectMake(CJToLeftMargin, 170, kScreenWidth -2*CJToLeftMargin, CJBottomBtnHeight))
        .btnFontSize(17)
        .btnNormalTitleColor([UIColor cjWhiteColor])
        .btnSelectTitleColor([UIColor cjWhiteColor])
        .btnBgColor([UIColor cjMainColorText])
        .btnTargetAction(self ,@selector(btnElectSignAction:))
        .btnText(@"电子签章")
        .btnCornerRadius(CJUICutCorner)
        ;
    }
    return _btnSign;
}

@end
